package com.netty.esc.common.global;

import com.netty.esc.entity.pojo.UserInfo;

public class UserCache {
    private static final ThreadLocal<UserInfo> USER_LOCAL = new ThreadLocal<>();

    /**
     * 添加当前登录用户方法
     */
    public static void addCurrentUser(UserInfo userInfo){
        USER_LOCAL.set(userInfo);
    }

    public static UserInfo getCurrentUser(){
        return USER_LOCAL.get();
    }


    /**
     * 防止内存泄漏
     */
    public static void remove(){
        USER_LOCAL.remove();
    }
}
